package com.personal.dao;


import com.personal.domain.Servicer;
import com.personal.util.partDisplay.ServicerPart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ServiceDao {


    @Select("select * from serviceprovider")
    List<Servicer> selectAll();

    @Select("select id,attributionRange,customerName,customerType,customerCode,contact,contactPhone from serviceprovider")
    List<ServicerPart> selectPartAll();

    @Select("select id,attributionRange,customerName,customerType,customerCode,contact,contactPhone from serviceprovider where customerName like CONCAT('%',#{name},'%')" +
            "and customerCode like CONCAT('%',#{code},'%')")
    List<ServicerPart> selectPartByKey(String name,String code);


    @Insert("insert into serviceprovider (id, customerType, customerName, customerCode,attributionRange," +
            "                                     customerAbbreviation, creationDate," +
            "                                     customerServiceManager, endangerQualifications," +
            "                                     contactPhone, remark, attachments," +
            "                                   contact) VALUE" +
            "                                    (null, #{customerType},#{customerName},#{customerCode},#{attributionRange}," +
            "                                    #{customerAbbreviation},#{creationDate}," +
            "                                    #{customerServiceManager},#{endangerQualifications}," +
            "                                    #{contactPhone},#{remark},#{attachments}," +
            "                                    #{contact})")
    int add(Servicer service);


    @Select("select * from serviceprovider where id=#{id}")
    Servicer getUpdateData(int id);
    @Update("update serviceprovider set customerType=#{customerType}, customerName=#{customerName}, customerCode=#{customerCode}," +
            "                                   customerAbbreviation=#{customerAbbreviation}, creationDate=#{creationDate}," +
            "                                   customerServiceManager=#{customerServiceManager}, endangerQualifications=#{endangerQualifications}," +
            "                                   contactPhone=#{contactPhone}, remark=#{remark}, attachments=#{attachments}," +
            "                                   contact=#{contact} where id=#{id}")
    int update(Servicer service);


    @Delete("delete from serviceprovider where id=#{id}}")
    int delete(int id);



}
